 <?php 

   /**
    *
    * FILE:          admin.php
    * LOCATION:      /root
    * REFERENCES:    none
    * FUNCTION:      main page template for user actions on consumer database.
    *                this page will render only after successful login.
    * DEPENDENCIES:  phpheader.php
    *                header.php
    *                nav.php
    *                cieSearch.php
    *                cieList.php
    *                cieEdit.php
    * 
    * --> LAST CODE MERGE FROM HALFSLIDE: 9-26-07
    * --> tested against local svn 10-2-07
    *
    * ==============================================================================
    * 
    * @version $Id: admin.php,v 0.1 2007/09/3
    * @copyright Copyright (c) none
    * @author Peter Holcomb
    * @license http://opensource.org/licenses/gpl-license.php GNU General 
    * Public License Version 2 (GPL v2)
    * 
    * ==============================================================================
    */



   //get headers to test for active session and render start of html
   include('includes/phpheader.php');
   include('includes/header.php');
	
   //db connection
   include('includes/db_connect.php');

   //pagination stuff
   include_once('./classes/pagination.class.php'); 
    
?>

   <!-- BEGIN PAGE AREA BELOW LOGIN ROW -->
   <div id="mainContentBig">
	  
      <!-- BEGIN LEFT NAVIGATION MENU -->
      <div id="mainContentSmallInnerCol" style="border-right:1px #ddd solid">
  	   
        <?php include('nav.php'); ?>
   
      </div>
      <!-- END LEFT NAVIGATION MENU -->
  


      <!-- BEGIN MAIN CONTENT AREA -->
      <div id="mainContentBigInnerCol">

<?php 
         
            /*
            
              next section determines which forms
              are displayed on the screen.
              users can search, view, and edit 
              existing consumer records in the database.
              new records are added from the cieSearch.php
              file.
            
            */
        
        			
            $action = $_GET["action"];
			
            if($action=="cie") {
		
               //SEARCH for consumer records		
               include('cieSearch.php');
			
            } else if($action=="cielistall") {
			
               //LIST all consumers in database	
               include('cieListAll.php');
			
            } else if($action=="cielistquery") {
			
               //LIST all consumers in database	
               include('cieListQuery.php');
			
            }else if($action=="cieedit") {
			
               //EDIT current consumer record	
               include('cieEdit.php');
			   
            } else if($action=="ir") {
				
               //GET information and referral form
               include('forms/irEntry.php');
			
            } else if($action=="enroll") {
				
               //GET information and referral form
               include('forms/enroll.php');
			
            }else{
 
               //THIS GREETING ADDED on 10-3-07

               echo "
                     <div id=\"usernotes\">                
                        <h2>Hello ".$loggedIn."!</h2>
                    ";
   
?>
                        <h5> Thanks for logging in.  Welcome to the <strong>HOCTIL's new, 
                             web-enabled Consumer Database System</strong>.  
                             In order to get started, just click on a <b>"module link"</b> 
                             at the left side of your screen.  Here are the current modules available to you:
                        </h5>

                        <br />
       
                            <ol>

                               <li><u><b>Consumer Information Entry</b></u><br/>
                                   Click on this module link to ENTER or EDIT a
                                   consumer intake, authorization to release information form, 
                                   ILP or CSR, case notes, or an I&R related to the 
                                   consumer's case file.
                               </li>

                               <li><u><b>Public I&R</b></u><br/>
                                   Use this module to enter I&R information you give to the
                                   general public.  This module allows you to get information
                                   about the caller and tracks issues people in the community
                                   ask your center to address.
                               </li>

                            </ol>

                        <hr />

                        <h2>Helpful Reminders</h2>


                         <!-- THIS TABLE EDITED ON 10-3-07 TO RENDER NEW TABLE STYLE -->
                         <!-- SET UP TABLE  FOR FULL RESULTSET-->
                         <table class="table1" summary="">

                            <caption style="font-size: 14px; color: #B01C1C; padding: 5px; font-weight: bold;">
                                A list of Public I&R Notes assigned to you.
                            </caption>

                            <thead> 
                               <tr>
                                  <th>Caller Name</th>
                                  <th>Phone Number</th>
                                  <th>Date Call Made</th>
                                  <th>Call Issue</th>
                                  <th>Received By</th>
                               </tr>
                            </thead>
                            <tbody>
                               <tr>

<?php
                                  //get query data
                                 $sqlStr = "SELECT irEntry.id,
                                                   irEntry.callerFirstName, 
                                                   irEntry.callerLastName, 
                                                   irEntry.callerPhoneNumber, 
                                                   irEntry.date, 
                                                   lst_ir_type.type, 
                                                   user.user_name
                                            FROM   irEntry, lst_ir_type, user 
                                            WHERE  irEntry.assignedTo 
                                            LIKE \"%".$loggedIn."%\"
                                            and    irEntry.type_id = lst_ir_type.id 
                                            and    irEntry.entered_by = user.id 
                                            ORDER BY irEntry.date asc";

                                 $query = mysql_query($sqlStr);

                                 //user ir assignments were found in the database
                                 if(mysql_num_rows($query)> 0){

                                 
                                      while($row = mysql_fetch_assoc($query)){
                                 
                                             $publicIrID        = $row["id"];
                                             $callerFirstName   = $row["callerFirstName"];
                                             $callerLastName    = $row["callerLastName"];
                                             $callerPhoneNumber = $row["callerPhoneNumber"];
                                             $irDate            = $row["date"];
                                             $callType          = $row["type"];
                                             $receivedBy        = $row["user_name"];

?>

                                             <tr>
                                                <td>
                                                   <a href="admin.php?action=ir&record=<?php echo $publicIrID; ?>">
                                                      <?php echo "$callerFirstName "."$callerLastName"; ?>
                                                   </a>
                                                </td>
                                                <td><?php echo "$callerPhoneNumber"; ?></td>
                                                <td><?php echo "$irDate"; ?></td>
                                                <td><?php echo "$callType"; ?></td>
                                                <td><?php echo "$receivedBy"; ?></td>
                                            </tr>

<?php

                                         //end table while
                                         }

                                      //end records found
                                      }else{

?>
                                           <tr colspan="4">
                                               <td><p>No I&Rs were assigned to you.</p></td>
                                           </tr>
                                            &nbsp;

<?php	

                                      //end if
                                      }

?>

                       </tbody>
                   </table>
                
               <br /><br />
  
                <hr/>
                <!-- end caller info -->

                 <h2>Have any questions?</h2>
                 <p>
                 The official blog for this database project will be up soon. The blog
                 will enable you to post questions about features, read about improvements
                 to the system, and comment on the path this project will take in the future.
                 If you have any questions or a need for different features, please
                 email me <a href="mailto:nickadeemus2002@gmail.com">at this address</a>
                 or reach me <a href="mailto:chrisv@arcil.com">here.</a>

                 Thanks!
                 Chris
                 </p>

             </div>
<?php
          }//end of last else

?> 
     
  
      </div>
      <!-- END MAIN CONTENT AREA -->

   </div>
   <!-- END PAGE AREA BELOW LOGIN ROW  -->

</body>
</html>